<template>
  <div class="selway border-bottom">
    <ul>
      <swiper :options="swiperOption">
        <swiper-slide v-for="(list,index) of pages" :key="index">
          <li v-for="item of list" :key="item.id">
            <img :src="item.imgurl">
            <p>{{item.wayname}}</p>
          </li>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </ul>
  </div>
</template>
<script>
export default { //  组件配置项
  name: 'HomeWay',
  props: {
    listway: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination'
        }
      }
    }
  },
  computed: {
    pages () {
      let arr = []
      this.listway.forEach((obj, index) => {
        let page = Math.floor(index / 8)
        if (!arr[page]) {
          arr[page] = []
        }
        arr[page].push(obj)
      })
      return arr
    }
  }
}
</script>

<style lang="stylus" scoped="scoped">
  .selway >>> .swiper-wrapper
    height 4rem
  .selway >>> .swiper-pagination-bullet-active
    background #00AFBE
  .selway
    width 100%
    margin-top 0.2rem
    height 4rem
    overflow hidden
    ul
      li
        float left
        width 25%
        text-align center
        p
          padding 0.2rem 0
          text-align center
        img
          width 50%
</style>
